import pyserial,time


ser=serial.Serial('COM1',9600,timeout=1)
ser.open()
print('COM1 OPEN')
data_in=ser.read()
if data_in=='XBOX CONTROLLER READY':
    print('XBOX CONTROLLER READY')
    time.sleep(1)
    print('3')
    time.sleep(1)
    print('2')
    time.sleep(1)
    print('1')
    ser.write('PC READY')
else:
    print('等待XBOX CONTROLLER连接')

def data_out(data):
    ser.write(data)
    print('PC SEND:'+data)

print('PC SEND:PC READY')   
print(input('开始手柄校准?y/n'))
while input()=='y':
    data_out('test')
    break
else:
    print('跳过手柄校准')

    



